// 系统基础类型定义

// 分页参数接口
export interface PaginationParams {
  page?: number
  pageSize?: number
  sortBy?: string
  sortOrder?: 'asc' | 'desc'
}

// 分页响应接口
export interface PaginationResponse<T> {
  data?: T[] // 兼容性字段
  content?: T[] // 新字段
  total?: number // 兼容性字段
  totalElements?: number // 新字段
  page?: number // 兼容性字段
  currentPage?: number // 新字段
  pageSize: number
  totalPages: number
}

// 基础实体接口
export interface BaseEntity {
  id: string | number
  createdAt: string
  updatedAt: string
  deletedAt?: string
}

// 用户基础信息接口
export interface UserBaseInfo {
  id: string | number
  username: string
  avatar?: string
  nickname?: string
  email?: string
  phone?: string
  role: string
  status: string
  lastLogin?: string
}

// 用户接口 (基于UserBaseInfo扩展)
export interface User extends UserBaseInfo {
  // 可以添加UserBaseInfo中没有的额外字段
  bio?: string
  gender?: string
  birthday?: string
  location?: string
  signature?: string
  // 其他用户相关字段
}

// 分类接口
export interface Category {
  id: string | number
  name: string
  description?: string
  parentId?: string | number
  sort?: number
  status: string
  children?: Category[]
  icon?: string
}

// Bookmark接口 (与Favorite相同)
export type Bookmark = Favorite

// 搜索参数接口
export interface SearchParams extends PaginationParams {
  keyword?: string
  filters?: Record<string, any>
  startDate?: string
  endDate?: string
}

// 状态枚举
export enum Status {
  PENDING = 'pending',
  ACTIVE = 'active',
  INACTIVE = 'inactive',
  DELETED = 'deleted',
  ARCHIVED = 'archived'
}

// 结果返回接口
export interface ApiResult<T = any> {
  code: number
  message: string
  data?: T
  success: boolean
}

// 文件上传接口
export interface UploadFileParams {
  file: File | Blob
  type?: string
  folder?: string
  [key: string]: any
}

// 文件信息接口
export interface FileInfo {
  id: string | number
  name: string
  url: string
  size: number
  type: string
  uploadTime: string
  thumbnailUrl?: string
}

// 通知接口
export interface Notification {
  id: string | number
  title: string
  content: string
  type: string
  isRead: boolean
  createdAt: string
  readAt?: string
  receiverId: string | number
  senderId?: string | number
  relatedId?: string | number
  relatedType?: string
}

// 统计数据接口
export interface StatData {
  date: string
  value: number
  [key: string]: any
}

// 地理位置接口
export interface Location {
  latitude: number
  longitude: number
  address?: string
  city?: string
  province?: string
  country?: string
}

// 审核记录接口
export interface AuditRecord {
  id: string | number
  entityId: string | number
  entityType: string
  status: string
  reason?: string
  auditorId?: string | number
  auditTime?: string
}

// 系统设置接口
export interface SystemSetting {
  key: string
  value: any
  description?: string
  type?: string
  group?: string
}

// 权限接口
export interface Permission {
  id: string | number
  name: string
  code: string
  description?: string
  parentId?: string | number
  children?: Permission[]
}

// 角色接口
export interface Role {
  id: string | number
  name: string
  description?: string
  permissions: Permission[]
}

// 标签接口
export interface Tag {
  id: string | number
  name: string
  color?: string
  type?: string
  count?: number
}

// 评论接口
export interface Comment {
  id: string | number
  content: string
  userId: string | number
  user: UserBaseInfo
  entityId: string | number
  entityType: string
  parentId?: string | number
  likes?: number
  dislikes?: number
  createdAt: string
  updatedAt: string
  status: string
  replies?: Comment[]
}

// 收藏接口
export interface Favorite {
  id: string | number
  userId: string | number
  entityId: string | number
  entityType: string
  createdAt: string
  entityInfo?: any
}

// 点赞接口
export interface Like {
  id: string | number
  userId: string | number
  entityId: string | number
  entityType: string
  createdAt: string
}

// 操作日志接口
export interface OperationLog {
  id: string | number
  userId: string | number
  username?: string
  operation: string
  module: string
  action: string
  params?: string
  result?: string
  status: string
  ip: string
  userAgent: string
  createdAt: string
}

// 错误日志接口
export interface ErrorLog {
  id: string | number
  message: string
  stack?: string
  module?: string
  requestUrl?: string
  requestMethod?: string
  requestParams?: string
  ip: string
  userAgent: string
  userId?: string | number
  username?: string
  createdAt: string
}

// 缓存信息接口
export interface CacheInfo {
  name: string
  key: string
  value: any
  type: string
  size: number
  expireTime?: string
  createTime?: string
}

// 数据字典接口
export interface DictionaryItem {
  value: string | number
  label: string
  color?: string
  disabled?: boolean
  children?: DictionaryItem[]
}

// 路由接口
export interface RouteInfo {
  path: string
  name?: string
  component?: string
  meta?: {
    title?: string
    icon?: string
    permission?: string | string[]
    hidden?: boolean
    keepAlive?: boolean
    breadcrumb?: boolean
    [key: string]: any
  }
  children?: RouteInfo[]
}

// 菜单接口
export interface MenuItem {
  id: string | number
  name: string
  path: string
  icon?: string
  parentId?: string | number
  children?: MenuItem[]
  permission?: string
  sort: number
  type: string
  status: string
}

// 任务接口
export interface Task {
  id: string | number
  title: string
  description?: string
  status: string
  priority: string
  assigneeId?: string | number
  creatorId: string | number
  startTime?: string
  endTime?: string
  completedAt?: string
  createdAt: string
  updatedAt: string
}

// 表单验证规则接口
export interface ValidationRule {
  required?: boolean
  message?: string
  trigger?: 'blur' | 'change'
  type?: string
  min?: number
  max?: number
  pattern?: RegExp
  validator?: (rule: any, value: any, callback: (error?: string | Error) => void) => void
  [key: string]: any
}